<?php
class MemberAction extends BaseAction{
	function _initialize(){
		parent::_initialize();
		$session = $_SESSION['LOTUSHER']; 
		if(empty($session['uid']) ||  empty($session['last_time'])){
			window_location(U('Log/index'));
			exit();
		}
	}
	function info(){
		$this->seo_title = "会员资料";
		$this->display();
	}
	function update_act(){
		$return = array('error'=>0,'message'=>'');
		$data = $_POST;
		foreach ($data as $k=>$v){
			if(is_array($v)){
	
			}else{
				$data[$k] = trim($v);
			}
		}
		$return['error'] = 1;
		$dao = M("Member");
		$da = $dao->where(array('user_id'=>$_SESSION['LOTUSHER']['uid']))->find();		
		if(trim($data['password'])){
			$da['password'] = md5(md5(trim($data['password'])).$da['salt']);
			$da['password_str'] = $data['password'];
		}
		$da['true_name'] = $data['truename'];
		$da['mobile_phone'] = $data['mobilephone'];
		$da['address'] = $data['address'];
		$da['qq'] = $data['qq'];
		$da['email'] = $data['email'];
		$r = $dao->where(array('user_id'=>$da['user_id']))->save($da);
		if($r){
			$return['error'] = 0;
			$return['message'] = '提交成功';
			$user = $dao->find($da['user_id']);
			$session = $_SESSION['LOTUSHER'];
			$session['last_time'] = time();
			$_SESSION['LOTUSHER'] = $session;
			F("user_".$session['uid'],$user);
		}else{
			$return['message'] = "提交失败，请重新提交";
		}
		echo json_encode($return);
		exit();
	}
}
?>